import { Form } from 'ant-design-vue'
import { ref } from 'vue'

const { useForm } = Form

export function useMenuForm() {
  const show = ref(false)
  const loading = ref(false)
  const formModel = ref({
    parentId: '0',
    path: '',
    component: '',
    redirect: '',
    isCache: 0,
    menuType: 'M',
    menuName: '',
    orderNum: 0,
    visible: '0',
    perms: '',
    status: '0',
    icon: ''
  } as ICreateMenuDTO)
  const formRules = ref({
    menuName: [{ required: true, message: '请输入菜单名称' }],
    orderNum: [{ required: true, message: '请输入显示排序' }],
    path: [{ required: true, message: '请输入路由地址' }]
  } as FormRules<ICreateMenuDTO>)

  const formRef = useForm(formModel, formRules)

  return {
    show,
    loading,
    formModel,
    formRef
  }
}
